//
//  WKPublishFolloVideoVC.m
//  WKMaybell
//
//  Created by 何文虎 on 2018/12/18.
//  Copyright © 2018 何文虎. All rights reserved.
//

#import "WKPublishFolloVideoVC.h"
#import "WKSubmitVideoCell.h"

@interface WKPublishFolloVideoVC ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableview;
@property(nonatomic,assign)BOOL isSpread;
@end

@implementation WKPublishFolloVideoVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViews];
}

- (void)initViews{
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.naviBar.title = @"发跟拍";
    // 关闭
    UIButton* closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //    [closeButton setBackgroundImage:[ImageUtils getImageResourceForName:@"close"] forState:UIControlStateNormal];
    closeButton.backgroundColor = BACK_COLOR;
    [closeButton addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
    closeButton.frame = CGRectMake(20, 30, 30, 30);
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:closeButton];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    self.tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, NavBarHeight, ScreenWidth, ScreenHeight-NavBarHeight) style:UITableViewStylePlain];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    _tableview.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view addSubview:self.tableview];
    
    NSArray *identiferArr = @[@"VIDEOADDVIDEO",@"VIDEOTAGVIEW",@"VIDEOCONTENVIEW"];
    for (int i = 0; i<identiferArr.count; i++) {
         NSString *identifer = identiferArr[i];
        [_tableview registerClass:[WKSubmitVideoCell class] forCellReuseIdentifier:identifer];
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSArray *identiferArr = @[@"VIDEOADDVIDEO",@"VIDEOTAGVIEW",@"VIDEOCONTENVIEW"];
    NSString *identifer = identiferArr[indexPath.row];
    WKSubmitVideoCell *cell = [tableView dequeueReusableCellWithIdentifier:identifer forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    UIView *footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 46)];
    UILabel *titleLb = [[UILabel alloc]initWithFrame:CGRectMake(12, 8, 150, 30)];
    titleLb.text = @"添加为我的日记";
    titleLb.font = PFSC_MediumFont(12);
    titleLb.textColor = UIColorFromHex(0x3C3C3C);
    [footView addSubview:titleLb];
    
    UIButton *spreadBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    spreadBtn.frame = CGRectMake(ScreenWidth-12-30, 8, 30, 30);
    [footView addSubview:spreadBtn];
    [spreadBtn addTarget:self action:@selector(spreadAction:) forControlEvents:UIControlEventTouchUpInside];
    return footView;
}

- (void)spreadAction:(UIButton*)sender{
    self.isSpread = sender.selected;
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:3 inSection:0];
    [self.tableview reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:(UITableViewRowAnimationFade)];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==0) {
        return 210;
    }
    if (indexPath.row==1) {
        return 46;
    }
    return 150;
}

- (void)closeAction{
    [self dismissViewControllerAnimated:NO completion:nil];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
